<template>
  <div id="project">
    <el-form :inline="true" :model="queryForm" class="demo-form-inline">
      <el-form-item label="姓名">
        <el-input v-model="queryForm.contactsName" placeholder="联系人姓名"></el-input>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input v-model="queryForm.phone" placeholder="联系人手机号"></el-input>
      </el-form-item>
      <el-form-item label="大客户行业">
        <el-input v-model="queryForm.secter" placeholder="联系人行业"></el-input>
      </el-form-item>
      <el-form-item label="单位">
        <el-input v-model="queryForm.company" placeholder="联系人单位"></el-input>
      </el-form-item>
    </el-form>

    <el-form :inline="true">
      <el-form-item label="省份">
        <el-select v-model="form.province" placeholder="省份">
          <el-option label="上海市" value="shanghai"></el-option>
          <el-option label="北京市" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="市区">
        <el-select v-model="form.city" placeholder="市区">
          <el-option label="直辖区"></el-option>
          <el-option label="县"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="区县">
        <el-select v-model="form.area" placeholder="区县">
          <el-option label="城"></el-option>
          <el-option label="乡"></el-option>
        </el-select>
      </el-form-item>
    </el-form>

    <el-form :inline="true">
      <el-button type="text" @click="dialogFormVisible = true"
        >添加大客户专员</el-button
      >
      <!-- <el-dialog :visible.sync="dialogFormVisible">
        <el-form :model="form">
          <el-form-item :label-width="formLabelWidth">
            <el-input
              v-model="form.contactsName"
              placeholder="姓名"
              autocomplete="off"
            ></el-input>
          </el-form-item>
          <el-form-item :label-width="formLabelWidth">
            <el-input
              v-model="form.password"
              placeholder="密码"
              autocomplete="off"
            ></el-input>
          </el-form-item>
          <el-form-item :label-width="formLabelWidth">
            <el-input
              v-model="form.phone"
              placeholder="电话"
              autocomplete="off"
            ></el-input>
          </el-form-item>
          <el-form-item :label-width="formLabelWidth">
            <el-input
              v-model="form.province"
              placeholder="省"
              autocomplete="off"
            ></el-input>
          </el-form-item>
          <el-form-item :label-width="formLabelWidth">
            <el-input
              v-model="form.city"
              placeholder="市"
              autocomplete="off"
            ></el-input>
          </el-form-item>
          <el-form-item :label-width="formLabelWidth">
            <el-input
              v-model="form.area"
              placeholder="区"
              autocomplete="off"
            ></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="dialogFormVisible = false">取 消</el-button>
          <el-button type="primary" @click="dialogFormVisible = false"
            >确 定</el-button
          >
        </div>
      </el-dialog> -->

      <!-- 弹框 -->
        <el-dialog title="添加大客户专员" :visible.sync="dialogFormVisible">
            <el-form :model="form">
                <el-form-item label="联系人" :label-width="formLabelWidth">
                    <el-input v-model="form.Sales_name" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="密码" :label-width="formLabelWidth">
                    <el-input v-model="form.password" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="电话" :label-width="formLabelWidth">
                    <el-input v-model="form.phone" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="省" :label-width="formLabelWidth">
                    <el-input v-model="form.province" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="市" :label-width="formLabelWidth">
                    <el-input v-model="form.city" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="区" :label-width="formLabelWidth">
                    <el-input v-model="form.area" autocomplete="off"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
                <el-button type="primary" @click="dialogFormVisible = false;addCus();">确 定</el-button>
            </div>
        </el-dialog>


      <el-form-item label="大客户专员：">
        <el-radio-group v-model="form.resource">
          <el-radio label="大客户专员"></el-radio>
          <el-radio label="大客户所属下级"></el-radio>
        </el-radio-group>
      </el-form-item>

      <el-from>
        <el-form-item>
          <el-button v-model="form.check" type="primary" @click="queryCustomerList"
            >查询</el-button
          >
          <el-button @click="resetForm">重置</el-button>
        </el-form-item>
      </el-from>
    </el-form>
    <el-table :data="list.slice((currentPage-1)*pagesize,currentPage*pagesize)" border style="width: 100%">
      <el-table-column prop="_id" label="ID" > </el-table-column>
      <el-table-column prop="contactsName" label="联系人" width="120"> </el-table-column>
      <el-table-column prop="phone" label="手机号"> </el-table-column>
      <el-table-column prop="timer" label="开通时间"> </el-table-column>
      <el-table-column prop="Sales_name" label="代理人"> </el-table-column>
      <el-table-column prop="sales_calls" label="联系电话"> </el-table-column>
      <el-table-column prop="province" label="省"> </el-table-column>
      <el-table-column prop="city" label="市"> </el-table-column>
      <el-table-column prop="area" label="区"> </el-table-column>
      <el-table-column prop="agent_level" label="帐号状态"> </el-table-column>
      <el-table-column prop="Wallet_details" label="操作"> </el-table-column>
    </el-table>
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :page-sizes="[4,8]"
        :page-size="100" layout="total, sizes, prev, pager, next, jumper" :total='list.length'>
    </el-pagination>
  </div>
</template>



<script>
import axios from "axios";

export default {
  data() {
    return {
      queryForm:{},
      formInline: {
        user: "",
        region: "",
      },
      dialogFormVisible: false,
      formLabelWidth:'120px',
      form: {
        Sales_name:"",
        password:"",
        phone:"",
        province:"",
        city:"",
        area:""
      },
      list: [{
        Account_status: true,
        Business_license: "",
        Company: "",
        Sales_name: "",
        Sociai_Credit: "",
        Wallet_details: {
          figure: "",
          inOrOut: "",
          inOutInfo: "",
          inOutDate: "",
        },

        length: "",
        __proto__: "",
        agent_level: "",
        area: "",
        city: "",
        contactsName: "",
        enterprise: "",
        identity_card: "",
        industry: "",
        password: "",
        phone: "",
        province: "",
        sales_calls: "",
        sales_number: "",
        timer: "",
        _id: "",
      }],
      currentPage: 1, // 默认开始页面
      pagesize: 4,
      total: 0,
    };
  },
  created() {
    this.getInfo();
  },
  methods: {
    handleSizeChange (size) {
      console.log(`每页 ${size} 条`)
      this.pagesize = size
    },
    handleCurrentChange (currentPage) {
      this.currentPage = currentPage
      console.log(`当前页: ${currentPage}`)
    },
    resetForm(){
      this.queryForm={};
      this.getInfo();
    },
    async queryCustomerList(){
      const {data:res} = await this.$axios.post('queryAllKeyAccounts',{
        contactsName:this.queryForm.contactsName
      });

      console.log(res.data);
      this.list = res.data;
      // console.log(this.queryForm.contactsName);
    },
    onSubmit() {
      console.log("submit!");
      //    axios
      //     .post("http://api/getAllKeyAccounts", {
      //       password: this.form.
      //     })
    },
    getInfo() {
        var that=this;
      axios
        .get("http://47.108.201.43:3000/api/getAllKeyAccounts")
        .then((res) => {
          console.log(res);
          that.list = res.data.data;
        });
    },
    async addCus(){
      // var _this = this;
      const {data:res} = await this.$axios.post('getBigCusList',{
        contactsName:this.form.Sales_name,
        password:this.form.password,
        phone:this.form.phone,
        province:this.form.province,
        city:this.form.city,
        area:this.form.area
      });
      console.log(res);


        },
  },
};
</script>